package com.company.planner.entity;

import com.haulmont.chile.core.annotations.NamePattern;
import com.haulmont.cuba.core.entity.StandardEntity;

import javax.persistence.*;

@Table(name = "PLANNER_HOT_OPERATION_RECORD")
@Entity(name = "planner_HotOperationRecord")
@NamePattern("%s|word")
public class HotOperationRecord extends StandardEntity {
    private static final long serialVersionUID = 3121040879212927847L;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "WORD_ID")
    private HotWords word;

    @Column(name = "SOURCE_WORDS")
    private String sourceWords;

    @Column(name = "WORDS")
    private String words;

    @Column(name = "OPERATION_STATE")
    private String operationState;

    @Column(name = "NODE_STATE")
    private Integer nodeState;

    public String getSourceWords() {
        return sourceWords;
    }

    public void setSourceWords(String sourceWords) {
        this.sourceWords = sourceWords;
    }

    public String getWords() {
        return words;
    }

    public void setWords(String words) {
        this.words = words;
    }

    public HotWords getWord() {
        return word;
    }

    public void setWord(HotWords word) {
        this.word = word;
    }

    public NodeState getNodeState() {
        return nodeState == null ? null : NodeState.fromId(nodeState);
    }

    public void setNodeState(NodeState nodeState) {
        this.nodeState = nodeState == null ? null : nodeState.getId();
    }

    public void setOperationState(OperationState operationState) {
        this.operationState = operationState == null ? null : operationState.getId();
    }

    public OperationState getOperationState() {
        return operationState == null ? null : OperationState.fromId(operationState);
    }

}